//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __CBUFFEREDOUTPUTSTREAM_H__
#define __CBUFFEREDOUTPUTSTREAM_H__

#include "_CBufferedOutputStream.h"

CarClass(CBufferedOutputStream)
{
public:
    CARAPI Close();

    CARAPI Flush();

    CARAPI Write(
        /* [in] */ Byte byte);

    CARAPI WriteBuffer(
        /* [in] */ const BufferOf<Byte> & buffer,
        /* [out] */ Int32 * pBytesWritten);

    CARAPI WriteBufferEx(
        /* [in] */ Int32 offset,
        /* [in] */ Int32 length,
        /* [in] */ const BufferOf<Byte> & buffer,
        /* [out] */ Int32 * pBytesWritten);

    CARAPI constructor(
        /* [in] */ IOutputStream * pStream);

    CARAPI constructor(
        /* [in] */ IOutputStream * pStream,
        /* [in] */ Int32 bufferSize);

    ~CBufferedOutputStream();

    CBufferedOutputStream() : m_pIos(NULL), m_pBuf(NULL) {}

private:
    ECode flushBuffer();
    IOutputStream * m_pIos;
    BufferOf<Byte>* m_pBuf;
};

#endif // __CBUFFEREDOUTPUTSTREAM_H__
